// 格式化字典
function formateDict(list, pid) {
  // console.log('父id', pid)
  let result = []
  for (let i = 0; i < list.length; i++) {
    let item = Object.assign(list[i])
    console.log('对比：', item.pid + '=' + pid)
    if (item.pid == pid) {
      console.log('进来了：', item.pid + '=' + pid)
      list.splice(i, 1)
      i--
      let sub_res = formateDict(list, item.id)
      item.child = sub_res
      result.push(item)
    }
  }
  return result
}
// 一些公关方法
const common = {
  // 格式化字典
  formateDict
}

module.exports = common
